home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / util / moni / Scout-src.lha / source / objects / scout_extras.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-09-17  |  25.9 KB  |  750 lines

  1. /**
  2.  * Scout - The Amiga System Monitor
  3.  *
  4.  *------------------------------------------------------------------
  5.  *
  6.  * This program is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; either version 2 of the License, or
  9.  * any later version.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program; if not, write to the Free Software
  18.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  *
  20.  * You must not use this source code to gain profit of any kind!
  21.  *
  22.  *------------------------------------------------------------------
  23.  *
  24.  * @author Andreas Gelhausen
  25.  * @author Richard Körber <rkoerber@gmx.de>
  26.  */
  27.  
  28.  
  29.  
  30. #include "system_headers.h"
  31.  
  32. extern struct GfxBase   *GfxBase;
  33. extern struct ExecBase  *SysBase;
  34. extern APTR AboutText;
  35.  
  36. UBYTE  updatetimetext[] = "1.0\0\0\0\0\0";
  37.  
  38. static APTR oldwindowptr;
  39.  
  40. BOOL GetPriority( UBYTE *nodename,
  41.                   LONG *pri )
  42. {
  43.     BOOL result = FALSE;
  44.     APTR priWin;
  45.  
  46.     if (priWin = PriorityWindowObject, End) {
  47.         set(priWin, MUIA_PriorityWin_ObjectName, nodename);
  48.         set(priWin, MUIA_PriorityWin_Priority, *pri);
  49.  
  50.         if (result = (BOOL)DoMethod(priWin, MUIM_PriorityWin_GetPriority)) {
  51.             get(priWin, MUIA_PriorityWin_Priority, pri);
  52.         }
  53.  
  54.  
  55.         MUI_DisposeObject(priWin);
  56.     }
  57.  
  58.     return result;
  59. }
  60.  
  61. void NoReqOn( void )
  62. {
  63.     struct Process *myprocess;
  64.  
  65.     myprocess = (struct Process *)FindTask(NULL);
  66.     oldwindowptr = myprocess->pr_WindowPtr;
  67.     myprocess->pr_WindowPtr = (APTR) -1;
  68. }
  69.  
  70. void NoReqOff( void )
  71. {
  72.     ((struct Process *)FindTask(NULL))->pr_WindowPtr = oldwindowptr;
  73. }
  74.  
  75. struct Library *MyOpenLibrary( UBYTE *libname,
  76.                                ULONG version )
  77. {
  78.     struct Library *libbase;
  79.  
  80.     if (!(libbase = OpenLibrary(libname, version))) {
  81.         aprintf("Failed to open %s version %ld!\n", libname, version);
  82.     }
  83.  
  84.     return libbase;
  85. }
  86.  
  87. void Flags2BinStr( UBYTE flags,
  88.                    UBYTE *str,
  89.                    ULONG maxlen )
  90. {
  91.     _snprintf(str, maxlen, "%%%ld%ld%ld%ld%ld%ld%ld%ld", (flags & (1 << 7)) ? 1 : 0,
  92.                                                          (flags & (1 << 6)) ? 1 : 0,
  93.                                                          (flags & (1 << 5)) ? 1 : 0,
  94.                                                          (flags & (1 << 4)) ? 1 : 0,
  95.                                                          (flags & (1 << 3)) ? 1 : 0,
  96.                                                          (flags & (1 << 2)) ? 1 : 0,
  97.                                                          (flags & (1 << 1)) ? 1 : 0,
  98.                                                          (flags & (1 << 0)) ? 1 : 0);
  99. }
  100.  
  101. void MySetContents( APTR textfield,
  102.                     UBYTE *fmt, ...)
  103. {
  104.     UBYTE *buf;
  105.  
  106.     if (buf = tbAllocVecPooled(globalPool, TMP_STRING_LENGTH)) {
  107.         va_list arg;
  108.  
  109.         va_start(arg, fmt);
  110.         _vsnprintf(buf, TMP_STRING_LENGTH, fmt, arg);
  111.         va_end(arg);
  112.  
  113.         nnset(textfield, MUIA_Text_Contents, buf);
  114.  
  115.         tbFreeVecPooled(globalPool, buf);
  116.     }
  117. }
  118.  
  119. void MySetContentsHealed( APTR textfield,
  120.                           UBYTE *fmt, ...)
  121. {
  122.     UBYTE *buf;
  123.  
  124.     if (buf = tbAllocVecPooled(globalPool, TMP_STRING_LENGTH)) {
  125.         va_list arg;
  126.  
  127.         va_start(arg, fmt);
  128.         _vsnprintf(buf, TMP_STRING_LENGTH, fmt, arg);
  129.         va_end(arg);
  130.  
  131.         healstring (buf);
  132.         nnset(textfield, MUIA_Text_Contents, buf);
  133.  
  134.         tbFreeVecPooled(globalPool, buf);
  135.     }
  136. }
  137.  
  138. void MySetStringContents( APTR textfield,
  139.                           UBYTE *fmt, ... )
  140. {
  141.     UBYTE *buf;
  142.  
  143.     if (buf = tbAllocVecPooled(globalPool, TMP_STRING_LENGTH)) {
  144.         va_list arg;
  145.  
  146.         va_start(arg, fmt);
  147.         _vsnprintf(buf, TMP_STRING_LENGTH, fmt, arg);
  148.         va_end(arg);
  149.  
  150.         nnset(textfield, MUIA_String_Contents, buf);
  151.  
  152.         tbFreeVecPooled(globalPool, buf);
  153.     }
  154. }
  155.  
  156. void SetCountText( APTR counttext,
  157.                    ULONG structcnt )
  158. {
  159.    MySetContents(counttext, MUIX_R "%04ld", structcnt);
  160. }
  161.  
  162. UBYTE *MyGetWindowTitle( UBYTE *type,
  163.                          UBYTE *title,
  164.                          ULONG maxlen )
  165. {
  166.     BOOL ok;
  167.     ULONG i;
  168.  
  169.     if (type[0] != 0x00) {
  170.         _snprintf(title, maxlen, "SCOUT: %s", type);
  171.     } else {
  172.         stccpy(title, "SCOUT", maxlen);
  173.     }
  174.  
  175.     Forbid();
  176.     ok = (FindPort("AMITCP") != NULL);
  177.     Permit();
  178.  
  179.     if (ok) {
  180.         UBYTE *host;
  181.  
  182.         host = (opts.Host) ? opts.Host : (UBYTE *)"localhost";
  183.  
  184.         if (type[0] != 0x00) {
  185.             _snprintf(title, maxlen, "SCOUT: %s   [ %s ]", type, host);
  186.         } else {
  187.             _snprintf(title, maxlen, "SCOUT   [ %s ]", host);
  188.         }
  189.     }
  190.  
  191.     for (i = 0; i < strlen(title); i++) title[i] = ToUpper(title[i]);
  192.  
  193.     return title;
  194. }
  195.  
  196. UBYTE *MyGetChildWindowTitle( UBYTE *part1,
  197.                             UBYTE *part2,
  198.                             UBYTE *title,
  199.                             ULONG maxlen )
  200. {
  201.     UBYTE *esc;
  202.  
  203.     _snprintf(title, maxlen, "%s: %s", part1, part2);
  204.     if (esc = strchr(title, '\033')) *esc = 0x00;
  205.  
  206.     return title;
  207. }
  208.  
  209. void ApplicationSleep( BOOL sleep )
  210. {
  211.     set(AP_Scout, MUIA_Application_Sleep, sleep);
  212. }
  213.  
  214. void RedrawActiveEntry( APTR list )
  215. {
  216.     DoMethod(list, MUIM_NList_Redraw, MUIV_NList_Redraw_Active);
  217. }
  218.  
  219. void RemoveActiveEntry( APTR list )
  220. {
  221.     DoMethod(list, MUIM_NList_Remove, MUIV_NList_Remove_Active);
  222. }
  223.  
  224. void InsertBottomEntry( APTR list,
  225.                         APTR entry )
  226. {
  227.     DoMethod(list, MUIM_NList_InsertSingle, entry, MUIV_List_Insert_Bottom);
  228. }
  229.  
  230. void InsertSortedEntry( APTR list,
  231.                         APTR entry )
  232. {
  233.     DoMethod(list, MUIM_NList_InsertSingle, entry, MUIV_List_Insert_Sorted);
  234. }
  235.  
  236. APTR GetActiveEntry( APTR list )
  237. {
  238.     APTR result = NULL;
  239.    
  240.     if (list) DoMethod(list, MUIM_NList_GetEntry, MUIV_NList_GetEntry_Active, &result);
  241.  
  242.     return result;
  243. }
  244.  
  245. struct MUI_NListtree_TreeNode *GetActiveTreeNode( APTR tree )
  246. {
  247.     struct MUI_NListtree_TreeNode *result = NULL;
  248.  
  249.     if (tree) result = (struct MUI_NListtree_TreeNode *)DoMethod(tree, MUIM_NListtree_GetEntry, MUIV_NListtree_GetEntry_ListNode_Active, MUIV_NListtree_GetEntry_Position_Active, 0);
  250.  
  251.     return result;
  252. }
  253.  
  254. APTR MyNListviewObject( ULONG id,
  255.                         UBYTE *format,
  256.                         struct Hook *conhook,
  257.                         struct Hook *deshook,
  258.                         struct Hook *dsphook,
  259.                         struct Hook *cmphook,
  260.                         BOOL input )
  261. {
  262.     APTR list;
  263.  
  264.     if (list = NListviewObject,
  265.         MUIA_CycleChain, TRUE,
  266.         MUIA_NListview_NList, NListObject,
  267.             MUIA_NList_Input, input,
  268.             MUIA_NList_Format, format,
  269.             MUIA_NList_Title, TRUE,
  270.             MUIA_NList_TitleSeparator, TRUE,
  271.             (conhook) ? MUIA_NList_ConstructHook2 : TAG_IGNORE, conhook,
  272.             (deshook) ? MUIA_NList_DestructHook2 : TAG_IGNORE, deshook,
  273.             (dsphook) ? MUIA_NList_DisplayHook2 : TAG_IGNORE, dsphook,
  274.             (cmphook) ? MUIA_NList_CompareHook2 : TAG_IGNORE, cmphook,
  275.             MUIA_NList_Exports, MUIV_NList_Exports_ColWidth | MUIV_NList_Exports_ColOrder,
  276.             MUIA_NList_Imports, MUIV_NList_Imports_ColWidth | MUIV_NList_Imports_ColOrder,
  277.             MUIA_NList_MinColSortable, 0,
  278.             // MUIA_NList_Pool, globalPool,
  279.             MUIA_ObjectID, id,
  280.         End,
  281.     End) {
  282.         DoMethod(list, MUIM_Notify, MUIA_NList_SortType,    MUIV_EveryTime, MUIV_Notify_Self, 3, MUIM_Set, MUIA_NList_TitleMark, MUIV_TriggerValue);
  283.         DoMethod(list, MUIM_Notify, MUIA_NList_SortType2,   MUIV_EveryTime, MUIV_Notify_Self, 3, MUIM_Set, MUIA_NList_TitleMark2, MUIV_TriggerValue);
  284.         DoMethod(list, MUIM_Notify, MUIA_NList_TitleClick,  MUIV_EveryTime, MUIV_Notify_Self, 4, MUIM_NList_Sort3, MUIV_TriggerValue, MUIV_NList_SortTypeAdd_2Values, MUIV_NList_Sort3_SortType_Both);
  285.         DoMethod(list, MUIM_Notify, MUIA_NList_TitleClick2, MUIV_EveryTime, MUIV_Notify_Self, 4, MUIM_NList_Sort3, MUIV_TriggerValue, MUIV_NList_SortTypeAdd_2Values, MUIV_NList_Sort3_SortType_2);
  286.     }
  287.  
  288.     return list;
  289. }
  290.  
  291. APTR MyNListtreeObject( APTR *tree,
  292.                         UBYTE *format,
  293.                         struct Hook *conhook,
  294.                         struct Hook *deshook,
  295.                         struct Hook *dsphook,
  296.                         struct Hook *cmphook,
  297.                         struct Hook *findhook,
  298.                         ULONG column )
  299. {
  300.     APTR list;
  301.  
  302.     list = NListviewObject,
  303.         MUIA_CycleChain, TRUE,
  304.         MUIA_NListview_NList, *tree = NListtreeObject,
  305.             InputListFrame,
  306.             MUIA_NListtree_DragDropSort, FALSE,
  307.             MUIA_NListtree_Format, format,
  308.             MUIA_NListtree_Title, TRUE,
  309.             (conhook) ? MUIA_NListtree_ConstructHook : TAG_IGNORE, conhook,
  310.             (deshook) ? MUIA_NListtree_DestructHook : TAG_IGNORE, deshook,
  311.             (dsphook) ? MUIA_NListtree_DisplayHook : TAG_IGNORE, dsphook,
  312.             MUIA_NListtree_CompareHook, (cmphook) ? cmphook : (struct Hook *)MUIV_NListtree_CompareHook_Tail,
  313.             (findhook) ? MUIA_NListtree_FindUserDataHook : TAG_IGNORE, findhook,
  314.             MUIA_NListtree_TreeColumn, column,
  315.             MUIA_NListtree_MultiSelect, MUIV_NListtree_MultiSelect_None,
  316.             // MUIA_NList_Pool, globalPool,
  317.         End,
  318.     End;
  319.  
  320.     return list;
  321. }
  322.  
  323. APTR MyBelowListview( APTR *text,
  324.                       APTR *count )
  325. {
  326.     APTR group;
  327.  
  328.     group = HGroup,
  329.         Child, *text = MyTextObject5(SPACE40),
  330.         Child, HGroup, MUIA_HorizWeight, 0,
  331.             Child, MyLabel(" Cnt:"),
  332.             Child, *count = MyTextObject4("0000"),
  333.         End,
  334.     End;
  335.  
  336.     return group;
  337. }
  338.  
  339. APTR MyTextObject( void)
  340. {
  341.     return (TextObject, MyTextFrame, End);
  342. }
  343.  
  344. APTR MyTextObject2( void )
  345. {
  346.     return (TextObject, MyTextFrame, MUIA_Text_SetMax, TRUE, End);
  347. }
  348.  
  349. APTR MyTextObject3( UBYTE *text )
  350. {
  351.     return (TextObject, MyTextFrame, MUIA_Text_Contents, text, End);
  352. }
  353.  
  354. APTR MyTextObject4( UBYTE *text )
  355. {
  356.     return (TextObject, MyTextFrame, MUIA_Text_SetMax, TRUE, MUIA_Text_Contents, text, End);
  357. }
  358.  
  359. APTR MyTextObject5( UBYTE *text )
  360. {
  361.     return (TextObject, MyTextFrame, MUIA_Text_SetMin, TRUE, MUIA_Text_Contents, text, End);
  362. }
  363.  
  364. APTR MyCheckmarkImage( void )
  365. {
  366.     return (ImageObject,
  367.         ImageButtonFrame,
  368.         MUIA_InputMode,      MUIV_InputMode_None,
  369.         MUIA_Image_Spec,     MUII_CheckMark,
  370.         MUIA_Image_Spec,     MUII_CheckMark,
  371.         MUIA_Image_FreeVert, TRUE,
  372.         MUIA_Background,     MUII_ButtonBack,
  373.         MUIA_ShowSelState,   FALSE,
  374.     End);
  375. }
  376.  
  377. void healstring( UBYTE *s )
  378. {
  379.     ULONG i = 0;
  380.  
  381.     while (s[i++] != 0x00) {
  382.         if (s[i] > 0xfe && s[i] <= 0x07) {
  383.             s[i] = 0x00;
  384.         } else if (s[i] > 0x07 && s[i] <= 0x11) {
  385.             s[i] = ' ';
  386.         }
  387.     }
  388. }
  389.  
  390. UBYTE *nonetest( UBYTE *s )
  391. {
  392.     ULONG i = 0;
  393.     UBYTE *t;
  394.  
  395.     if ((ULONG)s <= 0x200 || (s != NULL && s[0] == 0)) return txtNone;
  396.  
  397.     t = s;
  398.     while (t[i] != 0x00) {
  399.         if (!((t[i] > 8 && t[i] < 128) || (t[i] > 159 && t[i] != 215 && t[i] != 247 && t[i] != 255))) return txtNone;
  400.         i++;
  401.     }
  402.  
  403.     return s;
  404. }
  405.  
  406. BOOL IsReal( UBYTE *text )
  407. {
  408.     ULONG i = 0, punkte = 0;
  409.  
  410.     while (text[i]) {
  411.         if (text[i] == '.') {
  412.             if (punkte) return FALSE;
  413.             punkte++;
  414.         } else if (!isdigit(text[i])) {
  415.             return FALSE;
  416.         }
  417.         i++;
  418.     }
  419.  
  420.     return TRUE;
  421. }
  422.  
  423. BOOL IsHex( UBYTE *text,
  424.             LONG *result )
  425. {
  426.     ULONG i;
  427.  
  428.     *result = 0;
  429.  
  430.     if (text) {
  431.         if (text[0] == '$')
  432.             i = 1;
  433.         else if (!strnicmp("0x", text, 2))
  434.             i = 2;
  435.         else
  436.             return FALSE;
  437.  
  438.         if (strlen(text + i) < 9) {
  439.             *result = strtol(text + i, NULL, 16);
  440.             return TRUE;
  441.         }
  442.     }
  443.  
  444.     return FALSE;
  445. }
  446.  
  447. BOOL IsUHex( UBYTE *text,
  448.              ULONG *result)
  449. {
  450.     ULONG i;
  451.  
  452.     *result = 0;
  453.  
  454.     if (text) {
  455.         if (text[0] == '$')
  456.             i = 1;
  457.         else if (!strnicmp("0x", text, 2))
  458.             i = 2;
  459.         else
  460.             return FALSE;
  461.  
  462.         if (strlen(text + i) < 9) {
  463.             *result = strtoul(text + i, NULL, 16);
  464.             return TRUE;
  465.         }
  466.     }
  467.  
  468.     return FALSE;
  469. }
  470.  
  471. BOOL IsDec( UBYTE *text,
  472.             LONG *result)
  473. {
  474.     *result = 0;
  475.  
  476.     if (text != NULL && (strlen(text) < 12)) {
  477.         UBYTE *copy;
  478.  
  479.         if (copy = tbAllocVecPooled(globalPool, strlen(text) + 1)) {
  480.             UBYTE *p, *q;
  481.  
  482.             p = text;
  483.             q = copy;
  484.             while (*p != '\0' && isspace(*p)) *p++;
  485.             while (*p != '\0' && (*p == *decimalSeparator || isdigit(*p) || *p == '-')) {
  486.                 if (*p != *decimalSeparator) {
  487.                     *q = *p;
  488.                     q++;
  489.                 }
  490.                 p++;
  491.             }
  492.             *q = 0x00;
  493.  
  494.             *result = atol(copy);
  495.  
  496.             tbFreeVecPooled(globalPool, copy);
  497.  
  498.             return TRUE;
  499.         }
  500.     }
  501.  
  502.     return FALSE;
  503. }
  504.  
  505. LONG GetRamPointerCount( struct Library *lib )
  506. {
  507.     LONG max;
  508.     LONG count, offset;
  509.  
  510.     max = lib->lib_NegSize;
  511.  
  512.     count = 0;
  513.     for (offset = LIB_VECTSIZE; offset <= max; offset += LIB_VECTSIZE) {
  514.         struct JumpEntry *je;
  515.  
  516.         je = (struct JumpEntry *)((UBYTE *)lib - offset);
  517.  
  518.         if (je->je_JMPInstruction == 0x0000) {
  519.             // this cannot (or better: should not) happen
  520.             count = -1;
  521.             break;
  522.         } else if (je->je_JMPInstruction == 0x4ef9) {
  523.             if (points2ram(je->je_JumpAddress) || je->je_JumpAddress == NULL) count++;
  524.         }
  525.     }
  526.  
  527.     return count;
  528. }
  529.  
  530. struct List *FindListOfNode( struct Node *ln )
  531. {
  532.     struct List *lh = NULL;
  533.  
  534.     if (ln) {
  535.         while (ln->ln_Pred) ln = ln->ln_Pred;
  536.         lh = (struct List *)ln;
  537.     }
  538.  
  539.     return lh;
  540. }
  541.  
  542. LONG AllocListEntry( APTR pool,
  543.                      APTR source,
  544.                      ULONG size )
  545. {
  546.     void *result;
  547.  
  548.     if (result = tbAllocVecPooled(pool, size)) {
  549.         CopyMem(source, result, size);
  550.     }
  551.  
  552.     return (LONG)result;
  553. }
  554.  
  555. void FreeListEntry( APTR pool,
  556.                     APTR *entry )
  557. {
  558.     if (*entry) {
  559.         tbFreeVecPooled(pool, *entry);
  560.         *entry = NULL;
  561.     }
  562. }
  563.  
  564. static __asm __saveds void flushdevs_callfunc( void )
  565. {
  566.     FlushDevices();
  567. }
  568.  
  569. MakeHook(flushdevs_callhook, flushdevs_callfunc);
  570.  
  571. static __asm __saveds void flushfonts_callfunc( void )
  572. {
  573.     FlushFonts();
  574. }
  575.  
  576. MakeHook(flushfonts_callhook, flushfonts_callfunc);
  577.  
  578. static __asm __saveds void flushlibs_callfunc( void )
  579. {
  580.     FlushLibraries();
  581. }
  582.  
  583. MakeHook(flushlibs_callhook, flushlibs_callfunc);
  584.  
  585. static __asm __saveds void flushall_callfunc( void )
  586. {
  587.     FlushDevices();
  588.     FlushFonts();
  589.     FlushLibraries();
  590. }
  591.  
  592. MakeHook(flushall_callhook, flushall_callfunc);
  593.  
  594. static __asm __saveds void clearvect_callfunc( void )
  595. {
  596.     ClearResetVectors();
  597. }
  598.  
  599. MakeHook(clearvect_callhook, clearvect_callfunc);
  600.  
  601. enum menu_ids {
  602.     MENU_PROJECT = 1,
  603.         MENU_ABOUT, MENU_SNAPSHOT, MENU_QUIT,
  604.  
  605.     MENU_LIST = 10,
  606.        MENU_ALLOCATIONS, MENU_ASSIGNS, MENU_CLASSES, MENU_COMMODITIES, MENU_DEVICES, MENU_EXPANSIONS, MENU_FONTS,
  607.        MENU_INPUTHANDLERS, MENU_INTERRUPTS, MENU_LIBRARIES, MENU_LOCKS, MENU_LOWMEMORY, MENU_MEMORY, MENU_MOUNTS,
  608.        MENU_PORTS, MENU_RESIDENTS, MENU_COMMANDS, MENU_RESOURCES, MENU_SEMAPHORES, MENU_SCREENMODES, MENU_SYSTEM,
  609.        MENU_TASKS, MENU_TIMERS, MENU_VECTORS, MENU_WINDOWS, MENU_PATCHES, MENU_CATALOGS, MENU_AUDIOMODES,
  610.        MENU_RESETHANDLERS,
  611.  
  612.     MENU_OTHER = 50,
  613.         MENU_FLUSHDEVS, MENU_FLUSHFONTS, MENU_FLUSHLIBS, MENU_FLUSHALL, MENU_CLEARVECTORS
  614. };
  615.  
  616. static const struct NewMenu menu_list[] =
  617. {
  618.     { NM_TITLE, "Project",                NULL, 0, 0, (APTR)MENU_PROJECT        },
  619.     { NM_ITEM,  "?\0About...",            NULL, 0, 0, (APTR)MENU_ABOUT          },
  620. /*
  621.     { NM_ITEM,  NM_BARLABEL,              NULL, 0, 0, 0                         },
  622.     { NM_ITEM,  "Snapshot list columns",  NULL, 0, 0, (APTR)MENU_SNAPSHOT       },
  623. */
  624.     { NM_ITEM,  NM_BARLABEL,              NULL, 0, 0, 0                         },
  625.     { NM_ITEM,  "Q\0Quit",                NULL, 0, 0, (APTR)MENU_QUIT           },
  626.  
  627.     { NM_TITLE, "List",                   NULL, 0, 0, (APTR)MENU_LIST           },
  628.     { NM_ITEM,  "A\0Allocations",         NULL, 0, 0, (APTR)MENU_ALLOCATIONS    },
  629.     { NM_ITEM,  "G\0Assigns",             NULL, 0, 0, (APTR)MENU_ASSIGNS        },
  630.     { NM_ITEM,  "B\0Classes",             NULL, 0, 0, (APTR)MENU_CLASSES        },
  631.     { NM_ITEM,  "K\0Commodities",         NULL, 0, 0, (APTR)MENU_COMMODITIES    },
  632.     { NM_ITEM,  "D\0Devices",             NULL, 0, 0, (APTR)MENU_DEVICES        },
  633.     { NM_ITEM,  "X\0Expansions",          NULL, 0, 0, (APTR)MENU_EXPANSIONS     },
  634.     { NM_ITEM,  "F\0Fonts",               NULL, 0, 0, (APTR)MENU_FONTS          },
  635.     { NM_ITEM,  "H\0InputHandlers",       NULL, 0, 0, (APTR)MENU_INPUTHANDLERS  },
  636.     { NM_ITEM,  "I\0Interrupts",          NULL, 0, 0, (APTR)MENU_INTERRUPTS     },
  637.     { NM_ITEM,  "L\0Libraries",           NULL, 0, 0, (APTR)MENU_LIBRARIES      },
  638.     { NM_ITEM,  "O\0Locks",               NULL, 0, 0, (APTR)MENU_LOCKS          },
  639.     { NM_ITEM,  "J\0LowMemory",           NULL, 0, 0, (APTR)MENU_LOWMEMORY      },
  640.     { NM_ITEM,  "M\0Memory",              NULL, 0, 0, (APTR)MENU_MEMORY         },
  641.     { NM_ITEM,  "N\0Mount",               NULL, 0, 0, (APTR)MENU_MOUNTS         },
  642.     { NM_ITEM,  "P\0Ports",               NULL, 0, 0, (APTR)MENU_PORTS          },
  643.     { NM_ITEM,  "R\0Residents",           NULL, 0, 0, (APTR)MENU_RESIDENTS      },
  644.     { NM_ITEM,  "C\0Commands",            NULL, 0, 0, (APTR)MENU_COMMANDS       },
  645.     { NM_ITEM,  "U\0Resources",           NULL, 0, 0, (APTR)MENU_RESOURCES      },
  646.     { NM_ITEM,  "Z\0ScreenModes",         NULL, 0, 0, (APTR)MENU_SCREENMODES    },
  647.     { NM_ITEM,  "S\0Semaphores",          NULL, 0, 0, (APTR)MENU_SEMAPHORES     },
  648.     { NM_ITEM,  "Y\0System",              NULL, 0, 0, (APTR)MENU_SYSTEM         },
  649.     { NM_ITEM,  "T\0Tasks",               NULL, 0, 0, (APTR)MENU_TASKS          },
  650.     { NM_ITEM,  "E\0Timer",               NULL, 0, 0, (APTR)MENU_TIMERS         },
  651.     { NM_ITEM,  "V\0Vectors",             NULL, 0, 0, (APTR)MENU_VECTORS        },
  652.     { NM_ITEM,  "W\0Windows",             NULL, 0, 0, (APTR)MENU_WINDOWS        },
  653.     { NM_ITEM,  NM_BARLABEL,              NULL, 0, 0, 0                         },
  654.     { NM_ITEM,  "1\0Installed patches",   NULL, 0, 0, (APTR)MENU_PATCHES        },
  655.     { NM_ITEM,  "2\0Locale catalogs",     NULL, 0, 0, (APTR)MENU_CATALOGS       },
  656.     { NM_ITEM,  "3\0AHI AudioModes",      NULL, 0, 0, (APTR)MENU_AUDIOMODES     },
  657.     { NM_ITEM,  "4\0AHI ResetHandlers",   NULL, 0, 0, (APTR)MENU_RESETHANDLERS  },
  658.  
  659.     { NM_TITLE, "Other",                  NULL, 0, 0, (APTR)MENU_OTHER          },
  660.     { NM_ITEM,  "Flush devices",          NULL, 0, 0, (APTR)MENU_FLUSHDEVS      },
  661.     { NM_ITEM,  "Flush fonts",            NULL, 0, 0, (APTR)MENU_FLUSHFONTS     },
  662.     { NM_ITEM,  "Flush libraries",        NULL, 0, 0, (APTR)MENU_FLUSHLIBS      },
  663.     { NM_ITEM,  ".\0Flush all",           NULL, 0, 0, (APTR)MENU_FLUSHALL       },
  664.     { NM_ITEM,  NM_BARLABEL,              NULL, 0, 0, 0                         },
  665.     { NM_ITEM,  "!\0Clear reset vectors", NULL, 0, 0, (APTR)MENU_CLEARVECTORS   },
  666.  
  667.     { NM_END,   NULL,                     0,    0, 0, 0                         },
  668. };
  669.  
  670. APTR GetApplication( void )
  671. {
  672.     APTR app, win;
  673.     APTR menustrip;
  674.  
  675.     if (AP_Scout = app = ApplicationObject,
  676.         MUIA_Application_Title      , PROGNAME,
  677.         MUIA_Application_Version    , version_date,
  678.         MUIA_Application_Copyright  , COPYRIGHT,
  679.         MUIA_Application_Author     , AUTHOR,
  680.         MUIA_Application_Description, DESCRIPTION,
  681.         MUIA_Application_Base       , PROGNAME,
  682.         MUIA_Application_Commands   , arexx_list,
  683.         MUIA_Application_Menustrip, menustrip = MUI_MakeObject(MUIO_MenustripNM, menu_list, MUIO_MenustripNM_CommandKeyCheck),
  684.         MUIA_Application_DiskObject , GetDiskObject("PROGDIR:Scout"),
  685.         MUIA_Application_HelpFile   , "scout.guide",
  686.         SubWindow, WI_Main = win = MainWindowObject,
  687.             MUIA_Window_MaxChildWindowCount, (opts.SingleWindows) ? 1 : 0,
  688.         End,
  689.     End) {
  690.         struct PatchPort *pp;
  691.         struct SetManPort *sp;
  692.         struct Library *pc;
  693.         APTR menu;
  694.  
  695.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_ABOUT,         win,                     1, MUIM_MainWin_About);
  696.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_SNAPSHOT,      MUIV_Notify_Self,        2, MUIM_Application_Save, MUIV_Application_Save_ENV);
  697.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_SNAPSHOT,      MUIV_Notify_Self,        2, MUIM_Application_Save, MUIV_Application_Save_ENVARC);
  698.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_QUIT,          MUIV_Notify_Self,        2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
  699.  
  700.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_ALLOCATIONS,   win,                     1, MUIM_MainWin_ShowAllocations);
  701.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_ASSIGNS,       win,                     1, MUIM_MainWin_ShowAssigns);
  702.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_CLASSES,       win,                     1, MUIM_MainWin_ShowClasses);
  703.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_COMMODITIES,   win,                     1, MUIM_MainWin_ShowCommodities);
  704.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_DEVICES,       win,                     1, MUIM_MainWin_ShowDevices);
  705.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_EXPANSIONS,    win,                     1, MUIM_MainWin_ShowExpansions);
  706.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_FONTS,         win,                     1, MUIM_MainWin_ShowFonts);
  707.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_INPUTHANDLERS, win,                     1, MUIM_MainWin_ShowInputHandlers);
  708.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_INTERRUPTS,    win,                     1, MUIM_MainWin_ShowInterrupts);
  709.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_LIBRARIES,     win,                     1, MUIM_MainWin_ShowLibraries);
  710.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_LOCKS,         win,                     1, MUIM_MainWin_ShowLocks);
  711.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_LOWMEMORY,     win,                     1, MUIM_MainWin_ShowLowMemory);
  712.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_MEMORY,        win,                     1, MUIM_MainWin_ShowMemory);
  713.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_MOUNTS,        win,                     1, MUIM_MainWin_ShowMounts);
  714.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_PORTS,         win,                     1, MUIM_MainWin_ShowPorts);
  715.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_RESIDENTS,     win,                     1, MUIM_MainWin_ShowResidents);
  716.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_COMMANDS,      win,                     1, MUIM_MainWin_ShowCommands);
  717.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_RESOURCES,     win,                     1, MUIM_MainWin_ShowResources);
  718.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_SCREENMODES,   win,                     1, MUIM_MainWin_ShowScreenModes);
  719.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_SEMAPHORES,    win,                     1, MUIM_MainWin_ShowSemaphores);
  720.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_SYSTEM,        win,                     1, MUIM_MainWin_ShowSystem);
  721.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_TASKS,         win,                     1, MUIM_MainWin_ShowTasks);
  722.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_TIMERS,        win,                     1, MUIM_MainWin_ShowTimers);
  723.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_VECTORS,       win,                     1, MUIM_MainWin_ShowVectors);
  724.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_WINDOWS,       win,                     1, MUIM_MainWin_ShowWindows);
  725.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_PATCHES,       win,                     1, MUIM_MainWin_ShowPatches);
  726.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_CATALOGS,      win,                     1, MUIM_MainWin_ShowCatalogs);
  727.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_AUDIOMODES,    win,                     1, MUIM_MainWin_ShowAudioModes);
  728.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_RESETHANDLERS, win,                     1, MUIM_MainWin_ShowResetHandlers);
  729.  
  730.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_FLUSHDEVS,     MUIV_Notify_Application, 2, MUIM_CallHook, &flushdevs_callhook);
  731.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_FLUSHFONTS,    MUIV_Notify_Application, 2, MUIM_CallHook, &flushfonts_callhook);
  732.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_FLUSHLIBS,     MUIV_Notify_Application, 2, MUIM_CallHook, &flushlibs_callhook);
  733.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_FLUSHALL,      MUIV_Notify_Application, 2, MUIM_CallHook, &flushall_callhook);
  734.  
  735.         DoMethod(app, MUIM_Notify, MUIA_Application_MenuAction, MENU_CLEARVECTORS,  MUIV_Notify_Application, 2, MUIM_CallHook, &clearvect_callhook);
  736.  
  737.         Forbid();
  738.         pp = (struct PatchPort *)FindPort(PATCHPORT_NAME);
  739.         sp = (struct SetManPort *)FindPort(SETMANPORT_NAME);
  740.         pc = (struct Library *)OpenResource(PATCHRES_NAME);
  741.         Permit();
  742.  
  743.         menu = (APTR)DoMethod(menustrip, MUIM_FindUData, MENU_PATCHES);
  744.         set(menu, MUIA_Menuitem_Enabled, (pp != NULL || sp != NULL || pc != NULL));
  745.     }
  746.  
  747.     return app;
  748. }
  749.  
  750.